<!DOCTYPE html>
<html lang="en">
  <head>
    <title>
        Oracle-1 - rulerLwx Blog
      </title>
        <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
      content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-transform" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no,email=no,adress=no">
    
    <meta name="theme-color" content="#000000" />
    
    <meta http-equiv="window-target" content="_top" />
    
    
    <meta name="description" content="用户 新建用户 使用系统用户创建新用户时，一般赋予3个权限即可 connect dba resource 修改用户密码 sqlplus/ as sysdba SQL&amp;gt; alter user sys identified by admin; 用户已更改。 SQL&amp;gt; conn sys/admin as sysdba; 已连接。 删除一个用户及" />
    <meta name="generator" content="Hugo 0.73.0 with theme pure" />
    <title>Oracle-1 - rulerLwx Blog</title>
    
    
    <link rel="stylesheet" href="https://rulerLwx.gitee.io/css/style.min.c4bc7071f132c964c2116bca53b392933f377e5ca7b7051ed245187c621a2d3e.css">
    
    <link rel="stylesheet" href="https://cdn.staticfile.org/highlight.js/9.15.10/styles/github.min.css" async>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tocbot/4.4.2/tocbot.css" async>
    <meta property="og:title" content="Oracle-1" />
<meta property="og:description" content="用户 新建用户 使用系统用户创建新用户时，一般赋予3个权限即可 connect dba resource 修改用户密码 sqlplus/ as sysdba SQL&gt; alter user sys identified by admin; 用户已更改。 SQL&gt; conn sys/admin as sysdba; 已连接。 删除一个用户及" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://rulerLwx.gitee.io/2018/06/oracle-1/" />
<meta property="article:published_time" content="2018-06-04T10:01:47+08:00" />
<meta property="article:modified_time" content="2018-06-04T10:01:47+08:00" />
<meta itemprop="name" content="Oracle-1">
<meta itemprop="description" content="用户 新建用户 使用系统用户创建新用户时，一般赋予3个权限即可 connect dba resource 修改用户密码 sqlplus/ as sysdba SQL&gt; alter user sys identified by admin; 用户已更改。 SQL&gt; conn sys/admin as sysdba; 已连接。 删除一个用户及">
<meta itemprop="datePublished" content="2018-06-04T10:01:47&#43;08:00" />
<meta itemprop="dateModified" content="2018-06-04T10:01:47&#43;08:00" />
<meta itemprop="wordCount" content="1512">



<meta itemprop="keywords" content="" /><meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="Oracle-1"/>
<meta name="twitter:description" content="用户 新建用户 使用系统用户创建新用户时，一般赋予3个权限即可 connect dba resource 修改用户密码 sqlplus/ as sysdba SQL&gt; alter user sys identified by admin; 用户已更改。 SQL&gt; conn sys/admin as sysdba; 已连接。 删除一个用户及"/>

    <!--[if lte IE 9]>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/classlist/1.1.20170427/classList.min.js"></script>
      <![endif]-->

    <!--[if lt IE 9]>
        <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
        <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
      <![endif]-->
  </head>

  
  

  <body class="main-center theme-black" itemscope itemtype="http://schema.org/WebPage"><header class="header" itemscope itemtype="http://schema.org/WPHeader">
    <div class="slimContent">
      <div class="navbar-header">
        <div class="profile-block text-center">
          <a id="avatar" href="https://gitee.com/rulerLwx" target="_blank">
            <img class="img-circle img-rotate" src="https://rulerLwx.gitee.io/avatar.png" width="200" height="200">
          </a>
          <h2 id="name" class="hidden-xs hidden-sm">rulerLwx</h2>
          <h3 id="title" class="hidden-xs hidden-sm hidden-md">thinking...</h3>
          <small id="location" class="text-muted hidden-xs hidden-sm"><i class="icon icon-map-marker"></i>Guangzhou, China</small>
        </div><div class="search" id="search-form-wrap">
    <form class="search-form sidebar-form">
        <div class="input-group">
            <input type="text" class="search-form-input form-control" placeholder="Search" />
            <span class="input-group-btn">
                <button type="submit" class="search-form-submit btn btn-flat" onclick="return false;"><i
                        class="icon icon-search"></i></button>
            </span>
        </div>
        <div class="ins-search">
            <div class="ins-search-mask"></div>
            <div class="ins-search-container">
                <div class="ins-input-wrapper">
                    <input type="text" class="ins-search-input" placeholder="Type something..."
                        x-webkit-speech />
                    <button type="button" class="close ins-close ins-selectable" data-dismiss="modal"
                        aria-label="Close"><span aria-hidden="true">×</span></button>
                </div>
                <div class="ins-section-wrapper">
                    <div class="ins-section-container"></div>
                </div>
            </div>
        </div>
    </form>
</div>
        <button class="navbar-toggle collapsed" type="button" data-toggle="collapse" data-target="#main-navbar" aria-controls="main-navbar" aria-expanded="false">
          <span class="sr-only">Toggle navigation</span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
      </div>
      <nav id="main-navbar" class="collapse navbar-collapse" itemscope itemtype="http://schema.org/SiteNavigationElement" role="navigation">
        <ul class="nav navbar-nav main-nav">
            <li class="menu-item menu-item-home">
                <a href="/">
                    <i class="icon icon-home-fill"></i>
                  <span class="menu-title">Home</span>
                </a>
            </li>
            <li class="menu-item menu-item-archives">
                <a href="/posts/">
                    <i class="icon icon-archives-fill"></i>
                  <span class="menu-title">Archives</span>
                </a>
            </li>
            <li class="menu-item menu-item-categories">
                <a href="/categories/">
                    <i class="icon icon-folder"></i>
                  <span class="menu-title">Categories</span>
                </a>
            </li>
            <li class="menu-item menu-item-tags">
                <a href="/tags/">
                    <i class="icon icon-tags"></i>
                  <span class="menu-title">Tags</span>
                </a>
            </li>
            <li class="menu-item menu-item-about">
                <a href="/about/">
                    <i class="icon icon-cup-fill"></i>
                  <span class="menu-title">About</span>
                </a>
            </li>
        </ul>
      </nav>
    </div>
  </header>

<aside class="sidebar" itemscope itemtype="http://schema.org/WPSideBar">
  <div class="slimContent">
    
      <div class="widget">
    <h3 class="widget-title">Board</h3>
    <div class="widget-body">
        <div id="board">
            <div class="content">enjoy~
            </div>
        </div>
    </div>
</div>

      <div class="widget">
    <h3 class="widget-title"> Categories</h3>
    <div class="widget-body">
        <ul class="category-list">
            <li class="category-list-item"><a href="https://rulerLwx.gitee.io/categories/java-framework/" class="category-list-link">java-framework</a><span class="category-list-count">38</span></li>
            <li class="category-list-item"><a href="https://rulerLwx.gitee.io/categories/java-front-end/" class="category-list-link">java-front-end</a><span class="category-list-count">11</span></li>
            <li class="category-list-item"><a href="https://rulerLwx.gitee.io/categories/java-se/" class="category-list-link">java-se</a><span class="category-list-count">21</span></li>
            <li class="category-list-item"><a href="https://rulerLwx.gitee.io/categories/java-senior/" class="category-list-link">java-senior</a><span class="category-list-count">4</span></li>
            <li class="category-list-item"><a href="https://rulerLwx.gitee.io/categories/linux/" class="category-list-link">linux</a><span class="category-list-count">13</span></li>
            <li class="category-list-item"><a href="https://rulerLwx.gitee.io/categories/tools/" class="category-list-link">tools</a><span class="category-list-count">1</span></li>
            <li class="category-list-item"><a href="https://rulerLwx.gitee.io/categories/%E6%8A%80%E6%9C%AF%E6%9D%82%E7%83%A9/" class="category-list-link">技术杂烩</a><span class="category-list-count">4</span></li>
            <li class="category-list-item"><a href="https://rulerLwx.gitee.io/categories/%E6%95%B0%E6%8D%AE%E5%BA%93/" class="category-list-link">数据库</a><span class="category-list-count">15</span></li>
        </ul>
    </div>
</div>
      <div class="widget">
    <h3 class="widget-title"> Tags</h3>
    <div class="widget-body">
        <ul class="tag-list">
            
            
            <li class="tag-list-item"><a href="https://rulerLwx.gitee.io/tags/jvm/" class="tag-list-link">jvm</a><span
                    class="tag-list-count">1</span></li>
            
            
            <li class="tag-list-item"><a href="https://rulerLwx.gitee.io/tags/%E5%A4%9A%E7%BA%BF%E7%A8%8B/" class="tag-list-link">多线程</a><span
                    class="tag-list-count">2</span></li>
            
            
            <li class="tag-list-item"><a href="https://rulerLwx.gitee.io/tags/%E7%BD%91%E7%BB%9C%E7%BC%96%E7%A8%8B/" class="tag-list-link">网络编程</a><span
                    class="tag-list-count">3</span></li>
            
        </ul>

    </div>
</div>
      
<div class="widget">
    <h3 class="widget-title">Recent Posts</h3>
    <div class="widget-body">
        <ul class="recent-post-list list-unstyled no-thumbnail">
            <li>
                <div class="item-inner">
                    <p class="item-title">
                        <a href="https://rulerLwx.gitee.io/2020/07/%E8%87%AA%E5%B7%B1%E5%8A%A8%E6%89%8B%E4%B8%80%E6%89%B9%E9%87%8F%E7%A7%BB%E5%8A%A8%E9%87%8D%E5%91%BD%E5%90%8D%E6%96%87%E4%BB%B6/" class="title">自己动手（一）——批量移动、重命名文件</a>
                    </p>
                    <p class="item-date">
                        <time datetime="2020-07-27 17:50:02 &#43;0800 CST" itemprop="datePublished">2020-07-27</time>
                    </p>
                </div>
            </li>
            <li>
                <div class="item-inner">
                    <p class="item-title">
                        <a href="https://rulerLwx.gitee.io/2020/07/%E5%85%B3%E4%BA%8Einteger%E7%9A%84-128~127%E7%BC%93%E5%AD%98/" class="title">关于Integer的 -128~127缓存</a>
                    </p>
                    <p class="item-date">
                        <time datetime="2020-07-11 16:56:21 &#43;0800 CST" itemprop="datePublished">2020-07-11</time>
                    </p>
                </div>
            </li>
            <li>
                <div class="item-inner">
                    <p class="item-title">
                        <a href="https://rulerLwx.gitee.io/2020/07/%E8%B7%A8%E5%9F%9F%E9%97%AE%E9%A2%98/" class="title">跨域问题</a>
                    </p>
                    <p class="item-date">
                        <time datetime="2020-07-08 22:41:12 &#43;0800 CST" itemprop="datePublished">2020-07-08</time>
                    </p>
                </div>
            </li>
            <li>
                <div class="item-inner">
                    <p class="item-title">
                        <a href="https://rulerLwx.gitee.io/2020/07/%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2%E6%90%AD%E5%BB%BA/" class="title">个人博客搭建</a>
                    </p>
                    <p class="item-date">
                        <time datetime="2020-07-05 18:58:47 &#43;0800 CST" itemprop="datePublished">2020-07-05</time>
                    </p>
                </div>
            </li>
            <li>
                <div class="item-inner">
                    <p class="item-title">
                        <a href="https://rulerLwx.gitee.io/2020/07/mongodb-1/" class="title">MonggoDB-1</a>
                    </p>
                    <p class="item-date">
                        <time datetime="2020-07-03 18:58:47 &#43;0800 CST" itemprop="datePublished">2020-07-03</time>
                    </p>
                </div>
            </li>
        </ul>
    </div>
</div>
  </div>
</aside>

    
    
<aside class="sidebar sidebar-toc collapse" id="collapseToc" itemscope itemtype="http://schema.org/WPSideBar">
  <div class="slimContent">
    <h4 class="toc-title">Catalogue</h4>
    <nav id="toc" class="js-toc toc">

    </nav>
  </div>
</aside>
<main class="main" role="main"><div class="content">
  <article id="-" class="article article-type-" itemscope
    itemtype="http://schema.org/BlogPosting">
    
    <div class="article-header">
      <h1 itemprop="name">
  <a
    class="article-title"
    href="/2018/06/oracle-1/"
    >Oracle-1</a
  >
</h1>

      <div class="article-meta">
        
<span class="article-date">
  <i class="icon icon-calendar-check"></i>&nbsp;
<a href="https://rulerLwx.gitee.io/2018/06/oracle-1/" class="article-date">
  <time datetime="2018-06-04 10:01:47 &#43;0800 CST" itemprop="datePublished">2018-06-04</time>
</a>
</span>
<span class="article-category">
  <i class="icon icon-folder"></i>&nbsp;
  <a class="article-category-link" href="/categories/%E6%95%B0%E6%8D%AE%E5%BA%93/"> 数据库 </a>
</span>

        <span class="post-comment"><i class="icon icon-comment"></i>&nbsp;<a href="/2018/06/oracle-1/#comments"
            class="article-comment-link">Comments</a></span>
		<span class="post-wordcount hidden-xs" itemprop="wordCount">Word Count: 1512words</span>
		<span class="post-readcount hidden-xs" itemprop="timeRequired">Read Count: 4minutes </span>
      </div>
    </div>
    <div class="article-entry marked-body js-toc-content" itemprop="articleBody">
      <h1 id="用户">用户</h1>
<h2 id="新建用户">新建用户</h2>
<p>使用系统用户创建新用户时，一般赋予3个权限即可</p>
<ul>
<li>connect</li>
<li>dba</li>
<li>resource</li>
</ul>
<h2 id="修改用户密码">修改用户密码</h2>
<pre><code class="language-sql">sqlplus/ as sysdba

SQL&gt; alter user sys identified by admin;
用户已更改。
SQL&gt; conn sys/admin as sysdba;
已连接。
</code></pre>
<h2 id="删除一个用户及其相关数据">删除一个用户及其相关数据</h2>
<pre><code class="language-sql">drop user CHAXUN_CMP_ZCFG cascade
</code></pre>
<h1 id="表空间">表空间</h1>
<h2 id="查看表空间所在目录">查看表空间（所在目录）</h2>
<pre><code class="language-sql">SELECT * FROM Dba_Data_Files;
</code></pre>
<h2 id="创建表空间win">创建表空间（win)</h2>
<pre><code class="language-sql">CREATE TABLESPACE CSSP_TBS
         DATAFILE  'D:\DataBase\oracle\oradata\orcl\CSSP_TBS.DBF'
         SIZE 100M
         AUTOEXTEND ON
         NEXT 32M MAXSIZE UNLIMITED
         EXTENT MANAGEMENT LOCAL;
</code></pre>
<h2 id="查看表空间">查看表空间</h2>
<ul>
<li>查询所有的表空间</li>
</ul>
<pre><code class="language-sql">select distinct tablespace_name from dba_free_space
</code></pre>
<ul>
<li>查询用户或表所用表空间</li>
</ul>
<pre><code class="language-sql">select owner,table_name,tablespace_name from dba_tables;
</code></pre>
<h2 id="删除表空间">删除表空间</h2>
<pre><code>-删除空的表空间，但是不包含物理文件
drop tablespace tablespace_name;
--删除非空表空间，但是不包含物理文件
drop tablespace tablespace_name including contents;
--删除空表空间，包含物理文件
drop tablespace tablespace_name including datafiles;
--删除非空表空间，包含物理文件
drop tablespace tablespace_name including contents and datafiles;
--如果其他表空间中的表有外键等约束关联到了本表空间中的表的字段，就要加上CASCADE CONSTRAINTS
drop tablespace tablespace_name including contents and datafiles CASCADE CONSTRAINTS;
</code></pre>
<h1 id="数据库导入导出">数据库导入导出</h1>
<p>windows下在cmd窗口输入如下命令</p>
<pre><code>导出：
exp sisp_public/sisp_public@10.165.0.13/testdb owner='sisp_public'  file=D:\tecsun\sisp_public_20161012.dmp   log=D:\tecsun\sisp_public_20161012.log
exp sisp/sisp@10.165.0.13/testdb owner='sisp'  file=D:\tecsun\sisp_20161012.dmp   log=D:\tecsun\sisp_20161012.log

导入：
imp zzgs/j2yx@192.168.5.71/ZZWATER100  file=E:\zzgs20160306.dmp full=y  log=E:\impzzgs_2016-03-06.log
</code></pre>
<h1 id="查询">查询</h1>
<h2 id="分页">分页</h2>
<p>子查询利用rownum进行分页，做模板代码用</p>
<pre><code>select * from (
    select rownum rn, b.* from (
        select * from a 
    ) b where rownum &lt;= 40
) where rn &gt;= 30;
</code></pre>
<p>在rownum的基础上，另外还可以用rowid加快查询速度？？？</p>
<pre><code>select * from t_xiaoxi where rowid in (
    select rid from (
        select rownum rn,rid from (
            select rowid rid,cid from t_xiaoxi order by cid desc
        )
        where rownum &lt; 10000
    )
    where rn &gt; 9980
) order by cid desc;
</code></pre>
<p>资料参考：</p>
<p><img src="https://oscimg.oschina.net/oscnet/f5a7f557679d1d798faf4cbc989c37afc20.jpg" alt="image"></p>
<h2 id="wheregroup-byhaving">where、group by、having</h2>
<p>同时使用时，where用于筛选由from指定的数据对象；group by 用于对where的结果进行分组；having则是对group by 子句以后的分组数据进行过滤。</p>
<h2 id="左右连接">左右连接</h2>
<p>（一）非标准外连接</p>
<p><img src="https://oscimg.oschina.net/oscnet/febc3e6bfdf55862a84dfa3368f46aeca8a.jpg" alt="image"></p>
<p>（二）标准外连接</p>
<p><img src="https://oscimg.oschina.net/oscnet/1ff28545956738bf1d0a6db965173cfbef5.jpg" alt="image"></p>
<p>（三）自连接</p>
<p><img src="https://oscimg.oschina.net/oscnet/25a2db5e08c92772e1da74a72e6b7ad5908.jpg" alt="image"></p>
<h2 id="使用union">使用union</h2>
<p>1、使用 union 组合两个查询的结果集的基本规则如下：</p>
<p>1）所有查询中的列数和列的顺序必须相同；2）数据类型必须兼容。（默认去除重复列）</p>
<p>2、having与where：</p>
<p>1）having子句可以使用统计函数，where子句不可以；2）where,group by ,having同时使用时，注意顺序。</p>
<p>3、内、外连接</p>
<p>1）系统默认内连接；2）外连接：left join 左边的全出来； right join 右边的全出来</p>
<p><img src="https://oscimg.oschina.net/oscnet/ebf36eb69e72a41900a96045ac2f90ff5c9.jpg" alt="image"></p>
<h2 id="视图">视图</h2>
<ul>
<li>
<p>可更新视图</p>
<p>没有使用连接函数、集合函数、组函数。</p>
</li>
<li>
<p>插入数据</p>
<p>单表视图可插入，多表不可以。</p>
</li>
<li>
<p>修改数据</p>
<p>1）……；2）多表，一次只能修改一个表</p>
</li>
<li>
<p>删除数据</p>
</li>
</ul>
<p><img src="https://oscimg.oschina.net/oscnet/c2bab9fe829cb78ce625a86c05673d6e4ba.jpg" alt="image"></p>
<h1 id="序列">序列</h1>
<pre><code>创建序列，删除序列，得到序列的例子 

序列的创建
create sequence seq_newsId
increment by 1
start with 1
maxvalue 999999999;

得到序列的SQL语句

select seq_newsid.nextval from sys.dual;

删除序列的SQL

   DROP SEQUENCE seq_newsId；
</code></pre>
<p>语法：</p>
<pre><code>    CREATE SEQUENCE [user.]sequence_name
    [increment by n]
    [start with n]
    [maxvalue n | nomaxvalue]
    [minvalue n | nominvalue];
</code></pre>
<p>MAXVALUE最大值是28个9，用科学计数法将最大值记做1E28，换句话说，即使设置NOMAXVALUE，也是有这个最大值的。</p>
<p>NOCYCLE是默认值。</p>
<p>修改序列：</p>
<pre><code>    ALTER SEQUENCE [user.]sequence_name
    [INCREMENT BY n]
    [MAXVALUE n| NOMAXVALUE ]
    [MINVALUE n | NOMINVALUE]；
</code></pre>
<h1 id="函数">函数</h1>
<h2 id="系统函数">系统函数</h2>
<h3 id="常用函数">常用函数</h3>
<ul>
<li>
<p>decode()</p>
<p>if&hellip;then&hellip;else</p>
<p><img src="06B37BB7BEEA44FF882A5CF04DB70B17" alt="decode"></p>
</li>
<li>
<p>nvl(expr1,expr2)</p>
</li>
<li>
<p>nv2(expr1,expr2,expr3)</p>
</li>
<li>
<p>nullif(expr1,expr2)</p>
</li>
<li>
<p>coalesce(expr1,expr2,&hellip;,exprn)</p>
</li>
</ul>
<h3 id="字符串函数">字符串函数</h3>
<ul>
<li>
<p>length(char)，如<code>select * from user where length(name)=5</code></p>
</li>
<li>
<p>upper(char)，转换成大写</p>
</li>
<li>
<p>lower(char)，转换成小写</p>
</li>
<li>
<p>substr(char,m,n)，截取字符串</p>
<p>以首字母大写的方式显示所有员工的姓名</p>
<p><code>select upper(sbustr(ename,1,1)) || lower(substr(ename,2,length(ename)-1)) from emp;</code></p>
</li>
</ul>
<h3 id="数字函数">数字函数</h3>
<ul>
<li>trunc(n,[m])</li>
<li>ceil(n)</li>
<li>floor(n)</li>
<li>mod(m,n)</li>
<li>round(n,[m])，四舍五入，round(3.222,2)=3.22，round(3.222)=3</li>
</ul>
<h3 id="日期函数">日期函数</h3>
<ul>
<li>
<p>add_month(日期，月数)</p>
<p><code>select * from emp where sysdate &gt; add_month(hiredate,300);</code></p>
</li>
<li>
<p>trunc</p>
<p><code>select trunc(sysdate-hiredate) &quot;入职天数&quot;,ename from emp;</code></p>
<p><img src="C6E249B0D8F44E8089D727D9AF417865" alt="trunc"></p>
</li>
</ul>
<h3 id="转换函数">转换函数</h3>
<ul>
<li>
<p>to_char()</p>
<p>日期 to_char(hiredate,&lsquo;yyyy-mm-dd hh24:mi:ss&rsquo;)，货币 to_char(sal,&lsquo;L99999.99&rsquo;)，如 RMB999.00</p>
</li>
<li>
<p>to_date()</p>
<p><img src="1177CD3B3F5C423C84994218299396E1" alt="exchage">
<img src="C031BB88B3224C91873267FDECD44FB3" alt="exchage2">
<img src="5E3DF279148644C6A18E6682FF695C6E" alt="exchage3"></p>
</li>
</ul>
<h2 id="创建调用函数">创建、调用函数</h2>
<p>函数的参数只能是in模式</p>
<p>附参数模式：<a href="https://oscimg.oschina.net/oscnet/9d0cef25223d1ffa08edcbd362a42f32996.jpg">image</a></p>
<p>firstFun：</p>
<p><img src="https://oscimg.oschina.net/oscnet/941b129a55ec06e76c1a0fbc80d35a378d4.jpg" alt="image"></p>
<p>调用firstFun：</p>
<p><img src="https://oscimg.oschina.net/oscnet/184482caf00c1370bea506b857906f5d924.jpg" alt="image"></p>
<p>有参数的函数：</p>
<p><img src="https://oscimg.oschina.net/oscnet/03ce5dbb349b5f1927235d0bd49f9196eba.jpg" alt="image"></p>
<p>调用函数：</p>
<p><img src="https://oscimg.oschina.net/oscnet/0cb016aee31f712f376d239957a5ce750b8.jpg" alt="image"></p>
<h1 id="储存过程">储存过程</h1>
<p>储存过程与函数的唯一区别：函数有返回值，储存过程没有。？？？</p>
<p>无参的储存过程：
<img src="https://oscimg.oschina.net/oscnet/4626f1e664258344fbe6bd81cf740385be7.jpg" alt="image"></p>
<p>有参的储存过程：
<img src="https://oscimg.oschina.net/oscnet/1faa668d62f6be660f1de05a9e6c6a2226c.jpg" alt="image"></p>
<h2 id="游标">游标</h2>
<p>（一）没有使用循环</p>
<p><img src="https://oscimg.oschina.net/oscnet/be895080586624707e56fb2de84766acdbf.jpg" alt="image"></p>
<p>（二）使用循环</p>
<p><img src="https://oscimg.oschina.net/oscnet/e0bcb3c26ef1aec101193076840f4e8fd43.jpg" alt="image"></p>
<p>（三）有内循环的</p>
<p><img src="https://oscimg.oschina.net/oscnet/659435cf024248d11f12fb266c1a3cfc2bc.jpg" alt="image">
<img src="https://oscimg.oschina.net/oscnet/79221ee25798ae969dfc6f2d7a697fb05b9.jpg" alt="image"></p>
<p><!-- raw HTML omitted -->首页<!-- raw HTML omitted --></p>

    </div>
    <div class="article-footer">
<blockquote class="mt-2x">
  <ul class="post-copyright list-unstyled">
    <li class="post-copyright-link hidden-xs">
      <strong>Permalink: </strong>
      <a href="https://rulerLwx.gitee.io/2018/06/oracle-1/" title="Oracle-1" target="_blank" rel="external">https://rulerLwx.gitee.io/2018/06/oracle-1/</a>
    </li>
    <li class="post-copyright-license">
      <strong>License：</strong><a href="http://creativecommons.org/licenses/by/4.0/deed.zh" target="_blank" rel="external">CC BY 4.0 CN</a>
    </li>
  </ul>
</blockquote>

<div class="panel panel-default panel-badger">
  <div class="panel-body">
    <figure class="media">
      <div class="media-left">
        <a href="https://gitee.com/rulerLwx" target="_blank" class="img-burn thumb-sm visible-lg">
          <img src="https://rulerLwx.gitee.io/avatar.png" class="img-rounded w-full" alt="">
        </a>
      </div>
      <div class="media-body">
        <h3 class="media-heading"><a href="https://gitee.com/rulerLwx" target="_blank"><span class="text-dark">rulerLwx</span><small class="ml-1x">thinking...</small></a></h3>
        <div>Good Good Study, Day Day Up~</div>
      </div>
    </figure>
  </div>
</div>
    </div>
  </article>
<section id="comments">
    <div id="vcomments"></div>
</section>

</div><nav class="bar bar-footer clearfix" data-stick-bottom>
    <div class="bar-inner">
        <ul class="pager pull-left">
            <li class="prev">
                <a href="https://rulerLwx.gitee.io/2018/06/mysql-13-qa-%E5%91%BD%E4%BB%A4-%E9%99%84%E4%BB%B6/" title="MySQL-4-QA-命令-附件"><i
                        class="icon icon-angle-left"
                        aria-hidden="true"></i><span>&nbsp;&nbsp;Older</span></a>
            </li>
            <li class="next">
                <a href="https://rulerLwx.gitee.io/2018/06/oracle-2-qa/"
                    title="Oracle-2-QA"><span>Newer&nbsp;&nbsp;</span><i
                        class="icon icon-angle-right" aria-hidden="true"></i></a>
            </li>
            
            <li class="toggle-toc">
                <a class="toggle-btn collapsed" data-toggle="collapse" href="#collapseToc" aria-expanded="false"
                    title="Catalogue" role="button">
                    <span>[&nbsp;</span><span>Catalogue</span>
                    <i class="text-collapsed icon icon-anchor"></i>
                    <i class="text-in icon icon-close"></i>
                    <span>]</span>
                </a>
            </li>
        </ul>
        <div class="bar-right">
            <div class="share-component" data-sites="weibo,qq,wechat"
                data-mobile-sites="weibo,qq,qzone"></div>
        </div>
    </div>
</nav>

</main><footer class="footer" itemscope itemtype="http://schema.org/WPFooter">
<ul class="social-links">
    <li><a href="https://gitee.com/rulerLwx" target="_blank" title="gitee" data-toggle=tooltip data-placement=top >
            <i class="icon icon-gitee"></i></a></li>
    <li><a href="https://github.com/wolf-lea" target="_blank" title="github" data-toggle=tooltip data-placement=top >
            <i class="icon icon-github"></i></a></li>
</ul>
  <div class="copyright">
    &copy;2017  -
    2020
    <div class="publishby">
        Theme by <a href="https://github.com/xiaoheiAh" target="_blank"> xiaoheiAh </a>base on<a href="https://github.com/xiaoheiAh/hugo-theme-pure" target="_blank"> pure</a>.
    </div>
  </div>
</footer>

<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-MML-AM_SVG"></script>
<script type="text/x-mathjax-config">
    MathJax.Hub.Config({
            showMathMenu: false, //disables context menu
            tex2jax: {
            inlineMath: [ ['$','$'], ['\\(','\\)'] ]
           }
    });
</script>


<script src="https://cdn.jsdelivr.net/npm/jquery@3.4.1/dist/jquery.min.js"></script>
<script>
    window.jQuery || document.write('<script src="js/jquery.min.js"><\/script>')
</script>
<script type="text/javascript" src="https://cdn.staticfile.org/highlight.js/9.15.10/highlight.min.js"></script>
<script type="text/javascript" src="https://cdn.staticfile.org/highlight.js/9.15.10/languages/python.min.js" defer></script>
<script type="text/javascript" src="https://cdn.staticfile.org/highlight.js/9.15.10/languages/javascript.min.js" defer></script><script>
    hljs.configure({
        tabReplace: '    ', 
        classPrefix: ''     
        
    })
    hljs.initHighlightingOnLoad();
</script>
<script src="https://rulerLwx.gitee.io/js/application.min.bdeb64b910570b6c41badc6a05b7afb0c8ad9efd8525de3c7257d59e786326a3.js"></script>
<script src="https://rulerLwx.gitee.io/js/plugin.min.51ff8c7317566f82259170fa36e09c4493adc9b9378b427a01ad3f017ebac7dd.js"></script>

<script>
    (function (window) {
        var INSIGHT_CONFIG = {
            TRANSLATION: {
                POSTS: 'Posts',
                PAGES: 'Pages',
                CATEGORIES: 'Categories',
                TAGS: 'Tags',
                UNTITLED: '(Untitled)',
            },
            ROOT_URL: 'https:\/\/rulerLwx.gitee.io',
            CONTENT_URL: 'https:\/\/rulerLwx.gitee.io\/searchindex.json ',
        };
        window.INSIGHT_CONFIG = INSIGHT_CONFIG;
    })(window);
</script>
<script type="text/javascript" src="https://rulerLwx.gitee.io/js/insight.min.a343cd9a5a7698336b28ef3a7c16a3a1b1d2d5fb17dc8ed04022bbe08cc5459073a15bdafa3a8a58cdd56080784bdd69fa70b1ae8597565c799c57ed00f0e120.js" defer></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tocbot/4.4.2/tocbot.min.js"></script>
<script>
    tocbot.init({
        
        tocSelector: '.js-toc',
        
        contentSelector: '.js-toc-content',
        
        headingSelector: 'h1, h2, h3',
        
        hasInnerContainers: true,
    });
</script>

<script src="https://cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/valine"></script>
<script type="text/javascript">
    var GUEST = ['nick', 'mail', 'link'];
    var meta = 'nick,mail';
    meta = meta.split(',').filter(function (item) {
        return GUEST.indexOf(item) > -1;
    });
    new Valine({
        el: '#vcomments',
        verify: null ,
        notify: null ,
        appId: 'IyAB0PSPRazTPDxitO1ddQ7O-gzGzoHsz',
        appKey: '5rBJTq4KidYF33eXwvRVhtEH',
        placeholder: 'enjoy~',
        avatar: 'mm',
        meta: meta,
        pageSize: '10' || 10,
        visitor: false 
});
</script>

  </body>
</html>
